package cn.tkxqc.smallprogram.controller;

import cn.tkxqc.smallprogram.mapper.AddressMapper;
import cn.tkxqc.smallprogram.pojo.Address;
import cn.tkxqc.smallprogram.service.IAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
public class TestController {


    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Autowired
    private IAddressService iAddressService;

    @Autowired
    private AddressMapper addressMapper;

    @RequestMapping("/hello")
    @ResponseBody
    public List<Map<String, Object>> test(){

        List<Map<String, Object>> maps = jdbcTemplate.queryForList("select  * from address ");
        return maps;
    }

    @RequestMapping("/hello1")
    @ResponseBody
    public List<Map<String, Object>> testService(){
        List<Map<String, Object>> maps = iAddressService.queryForList();
        return maps;
    }

    @RequestMapping("/hello2")
    @ResponseBody
    public List<Address> testMapper(){
        List<Address> maps = addressMapper.selectList(null);
        return maps;
    }

}
